#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/7/29
# @Author  : YunZhen
# @File    : signals.py
# @Software: PyCharm
"""

"""
from django.core.exceptions import ValidationError
from django.db.models.signals import pre_save
from django.dispatch import receiver
from .models import FilmToCompany

@receiver(pre_save, sender=FilmToCompany)
def enforce_film_company_constraints(sender, instance, **kwargs):
    """
    强制执行条件唯一约束（信号级别）
    """
    try:
        # 执行模型验证
        instance.full_clean()
    except ValidationError as e:
        # 处理验证错误
        raise e